#ifndef QMYIMAGEBUTTON_H
#define QMYIMAGEBUTTON_H

#include <QObject>
#include <QWidget>

#ifdef quc
class Q_DECL_EXPORT QMyImageButton
#else
class QMyImageButton : public QWidget
#endif
{
    Q_OBJECT
    Q_ENUMS(ButtonStyle)
    Q_PROPERTY(bool isChecked READ getChecked WRITE setChecked)
    Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle)
public:
    explicit QMyImageButton(QWidget *parent = nullptr);

    enum ButtonStyle
    {
        ButtonStyle_1 = 0,
        ButtonStyle_2 = 1,
        ButtonStyle_3 = 2,
    };

protected:
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void paintEvent(QPaintEvent *event);

private:
    bool isChecked;

    ButtonStyle buttonStyle;

    QString strImgOffFile;

    QString strImgOnFile;

    QString strImgFile;

public:
    bool getChecked() const;
    ButtonStyle getButtonStyle() const;
    virtual QSize sizeHint() const;
    virtual QSize minimumSizeHint() const;

public Q_SLOTS:
    // 设置是否选中
    void setChecked(bool isChecked);
    // 设置按钮样式
    void setButtonStyle(const QMyImageButton::ButtonStyle& buttonstyle);

Q_SIGNALS:
    void checkedChangeed(bool checked);

};

#endif // QMYIMAGEBUTTON_H
